import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * This class move the scroll in the world, also sets the counter that will permit the scroll to move or not.
 * 
 * @author Manuel Nava 
 * @version 1.0
 */
public class Animation extends Actor
{
    /**
     * The method act is empty.
     */
    public void act() 
    {
        // Add your action code here.
    }   
    
    /**
     * This method moves the animation scroll classes and set the counters that let the scroll to move.
     */
    public void move()
    {
        if(Greenfoot.isKeyDown("right"))
           ((CaveWorld)(getWorld())).setCont(((CaveWorld)(getWorld())).getCont()+5);
        if(Greenfoot.isKeyDown("left"))
           if(((CaveWorld)(getWorld())).getCont()>0)
             ((CaveWorld)(getWorld())).setCont(((CaveWorld)(getWorld())).getCont()-5);
        if(((CaveWorld)(getWorld())).getCont()>0)
        {
          if(Greenfoot.isKeyDown("left")&&((CaveWorld)(getWorld())).getMove()==true)
            setLocation(getX()+5,getY());
          if(Greenfoot.isKeyDown("right")&&((CaveWorld)(getWorld())).getMove()==true)
            setLocation(getX()-5,getY());
        }
    }
}
